package oj;

/**
 * @author 郝文雪
 * @date 2022/7/16 20:45
 * @Description 汉明距离 Brian Kernighan 算法
 */
public class LC461 {
    public int hammingDistance(int x, int y) {
        int k=x^y;
        return countOnes(k);

    }
    private int countOnes(int k){
        int sum=0;
        while(k!=0){
            k=k&(k-1);
            sum++;
        }
        return sum;
    }
}
